/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.appspot.trick.it.admin.task;

import com.appspot.trick.it.admin.api.GaeArticleAPIService;
import com.appspot.trick.it.admin.controller.MainController;
import com.appspot.trick.it.admin.model.ArticleModel;
import javafx.concurrent.Service;
import javafx.concurrent.Task;

/**
 *
 * @author takahara
 */
public class ArticleGetByKeyTask extends Service<ArticleModel> {

    private String key;


    /**
     * コンストラクタ
     *
     * @param key
     */
    public void run(String key) {
        this.key = key;
        this.restart();
    }

    @Override
    protected Task<ArticleModel> createTask() {
        return new Task<ArticleModel>() {

            @Override
            protected ArticleModel call() throws Exception {
                GaeArticleAPIService gaeService = new GaeArticleAPIService(MainController.getInstance().getSiteMstEntity());

                return gaeService.getByKey(key);
            }
        };

    }

}
